<?php
namespace app\admin\controller;
use app\BaseController;
use think\facade\Cache;
use think\facade\Db;
use think\facade\Request;
use think\facade\Route;
use think\facade\View;

class Order extends BaseController
{
    public function orderList()
    {
        $keywords = Request::param('keywords');
        $acity = Request::param('acity');
        $time = Request::param('time');
        $times = Request::param('times');
        $jia = Request::param('jia');
        $post = Request::post();
        $where=[];
        if (isset( $keywords) && !empty( $keywords))$where[] = ['order_sn','like',"%{$keywords}%"];
        if (isset($time) && !empty($time))  $where[] = ['addtime','between time',$times.','.$time];
        if (isset($acity) && !empty($acity))  $where[] = ['acity','<=',$post['acity']];
        if (isset($jia) && !empty($jia))  $where[] = ['acity','>=',$post['jia']];
        if (isset($post['cid']) && !empty($post['cid']))   $where[] = ['order_status','=',$post['cid']];

       View::assign($post);
        $list = Db::table('ecm_order')
            ->alias('a')
            ->join('ecm_order_status u','a.status=u.status_id')
            ->where($where)
            ->select();
        $list = Db::name('order')
            ->alias('a')
            ->join('ecm_order_status u','a.status=u.status_id')
            ->where($where)
            ->paginate([
            'list_rows' =>5,
            'query'   =>  [
                'id'=>1,
                'name'  =>'tang'
            ]

        ]);
        View::assign('list',$list);
        $cha = Db::table('ecm_order_status')
            ->select();
        View::assign('cha',$cha);

        return View::fetch();
    }
    public function orderDetail()
    {
        return view();
    }



}